Module:Citation/CS1: Difference between revisions
hmmm, I see how spaces are currently handled
m>Dragons flight (testing) |
m>Dragons flight (hmmm, I see how spaces are currently handled) |
||
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. | Note: we use string function here, rather than ustring functions. | ||
This has considerably faster performance and should work correctly as | This has considerably faster performance and should work correctly as | ||
long as the duplicate_char | long as the duplicate_char is strict ASCII. The strings | ||
in tbl may be ASCII or UTF8. | in tbl may be ASCII or UTF8. | ||
]] | ]] | ||
Line 107: | Line 107: | ||
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 116: | 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 .. value:sub(2); | |||
elseif str:sub(-3,-1) == duplicate_char .. "''" then | elseif str:sub(-3,-1) == duplicate_char .. "''" then | ||
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 |