Module:Citation/CS1: Difference between revisions
note to self, don't edit old versions
m>Dragons flight (fix) |
m>Dragons flight (note to self, don't edit old versions) |
||
Line 95: | Line 95: | ||
end | end | ||
function safejoin( tbl, duplicate_char, | function safejoin( tbl, duplicate_char ) | ||
--[[ | |||
Note: we use string function here, rather than ustring functions. | |||
This has considerably faster performance and should work correctly as | |||
long as the duplicate_char is strict ASCII. The strings | |||
in tbl may be ASCII or UTF8. | |||
]] | |||
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 | ||
if str == '' then | if str == '' then | ||
Line 108: | Line 113: | ||
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 | str = str .. value:sub(2); | ||
elseif str:sub(-3,-1) == duplicate_char .. "''" then | elseif str:sub(-3,-1) == duplicate_char .. "''" then | ||
str = str | str = str .. value:sub(2); | ||
else | else | ||
str = str | str = str .. value; | ||
end | end | ||
else | else | ||
str = str | str = str .. value; | ||
end | end | ||
end | end | ||
Line 937: | Line 942: | ||
end | end | ||
text = Authors .. Date .. Chapter .. Editors .. tcommon | text = Authors .. Date .. Chapter .. Editors .. tcommon | ||
text = safejoin( {text, pgtext, idcommon}, sepc | text = safejoin( {text, pgtext, idcommon}, sepc ); | ||
elseif ( "" ~= Editors) then | elseif ( "" ~= Editors) then | ||
if ( "" ~= Date ) then | if ( "" ~= Date ) then |