Module:Citation/CS1: Difference between revisions
fix
m>Dragons flight (hmmm, I see how spaces are currently handled) |
m>Dragons flight (fix) |
||
Line 95: | Line 95: | ||
end | end | ||
function safejoin( tbl, duplicate_char ) | function safejoin( tbl, duplicate_char, space_char ) | ||
local str = ''; | local str = ''; | ||
for _, value in ipairs( tbl ) do | for _, value in ipairs( tbl ) do | ||
if value == nil then value = ''; end | if value == nil then value = ''; end | ||
-- Trim spaces | |||
value = value:match( '^%s*(.-)%s*$' ); | |||
if str == '' then | if str == '' then | ||
Line 113: | Line 108: | ||
if value:sub(1,1) == duplicate_char then | if value:sub(1,1) == duplicate_char then | ||
if str:sub(-1,-1) == duplicate_char then | if str:sub(-1,-1) == duplicate_char then | ||
str = str .. value:sub(2); | str = str .. space_char .. value:sub(2); | ||
elseif str:sub(-3,-1) == duplicate_char .. "''" then | elseif str:sub(-3,-1) == duplicate_char .. "''" then | ||
str = str .. value:sub(2); | str = str .. space_char .. value:sub(2); | ||
else | else | ||
str = str .. value; | str = str .. space_char .. value; | ||
end | end | ||
else | else | ||
str = str .. value; | str = str .. space_char .. value; | ||
end | end | ||
end | end | ||
Line 942: | Line 937: | ||
end | end | ||
text = Authors .. Date .. Chapter .. Editors .. tcommon | text = Authors .. Date .. Chapter .. Editors .. tcommon | ||
safejoin( {text, pgtext, idcommon}, sepc, ' ' ); | text = safejoin( {text, pgtext, idcommon}, sepc, ' ' ); | ||
elseif ( "" ~= Editors) then | elseif ( "" ~= Editors) then | ||
if ( "" ~= Date ) then | if ( "" ~= Date ) then | ||
Line 959: | Line 954: | ||
end | end | ||
text = Editors .. Date .. Chapter .. tcommon | text = Editors .. Date .. Chapter .. tcommon | ||
text = safejoin( {text, pgtext, idcommon}, sepc | text = safejoin( {text, pgtext, idcommon}, sepc ); | ||
else | else | ||
if ( "" ~= Date ) then | if ( "" ~= Date ) then | ||
Line 968: | Line 963: | ||
end -- endif ""~=Date | end -- endif ""~=Date | ||
text = Chapter .. tcommon .. Date | text = Chapter .. tcommon .. Date | ||
text = safejoin( {text, pgtext, idcommon}, sepc | text = safejoin( {text, pgtext, idcommon}, sepc ); | ||
end | end | ||