Jump to content

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, space_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 and space_char are strict ASCII.  The strings
     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
       
        -- Trim spaces
        value = value:match( '^%s*(.-)%s*$' );
          
          
         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
                     if string.len( value ) > 1 then
                     str = str .. value:sub(2);
                        str = str .. space_char .. value:sub(2);
                    end                   
                 elseif str:sub(-3,-1) == duplicate_char .. "''" then                   
                 elseif str:sub(-3,-1) == duplicate_char .. "''" then                   
                     if string.len( value ) > 1 then
                     str = str .. value:sub(2);
                        str = str .. space_char .. value:sub(2);
                    end                   
                 else
                 else
                     str = str .. space_char .. value;
                     str = str .. value;
                 end
                 end
             else
             else
                 str = str .. space_char .. value;
                 str = str .. value;
             end
             end
         end
         end
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.