Module:Citation/CS1: Difference between revisions
testing
m>Dragons flight (code cleanup) |
m>Dragons flight (testing) |
||
Line 94: | Line 94: | ||
end | end | ||
end | end | ||
function safejoin( tbl, duplicate_char, space_char ) | |||
local str = ''; | |||
for _, value in ipairs( tbl ) do | |||
if value == nil then value = ''; end | |||
-- Trim spaces | |||
value = value:match( '^%s*(.-)%s*$' ); | |||
if str == '' then | |||
str = value; | |||
elseif value ~= '' then | |||
if value:sub(1,1) == duplicate_char then | |||
if str:sub(-1,-1) == duplicate_char then | |||
str = str .. space_char .. value:sub(2); | |||
elseif str:sub(-3,-1) == duplicate_char .. "''" then | |||
str = str .. space_char .. value:sub(2); | |||
else | |||
str = str .. space_char .. value; | |||
end | |||
else | |||
str = str .. space_char .. value; | |||
end | |||
end | |||
end | |||
return str; | |||
end | |||
function selectyear( str ) | function selectyear( str ) | ||
Line 910: | Line 937: | ||
end | end | ||
text = Authors .. Date .. Chapter .. Editors .. tcommon | text = Authors .. Date .. Chapter .. Editors .. tcommon | ||
safejoin( {text, pgtext, idcommon}, sepc, ' ' ); | |||
elseif ( "" ~= Editors) then | elseif ( "" ~= Editors) then | ||
if ( "" ~= Date ) then | if ( "" ~= Date ) then | ||
Line 930: | Line 954: | ||
end | end | ||
text = Editors .. Date .. Chapter .. tcommon | text = Editors .. Date .. Chapter .. tcommon | ||
text = safejoin( {text, pgtext, idcommon}, sepc, ' ' ); | |||
else | else | ||
if ( "" ~= Date ) then | if ( "" ~= Date ) then | ||
Line 942: | Line 963: | ||
end -- endif ""~=Date | end -- endif ""~=Date | ||
text = Chapter .. tcommon .. Date | text = Chapter .. tcommon .. Date | ||
text = safejoin( {text, pgtext, idcommon}, sepc, ' ' ); | |||
end | end | ||