Jump to content

Module:Citation/CS1: Difference between revisions

code cleanup
m>Dragons flight
(test whether that is unnecessary)
m>Dragons flight
(code cleanup)
Line 83: Line 83:
function hyphentodash( str )
function hyphentodash( str )
     return str:gsub( '-', '–' );
     return str:gsub( '-', '–' );
end
function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == "'" then str = "<span />" .. str; end
        if str:sub(-1,-1) == "'" then str = str .. "<span />"; end
        return str;
    end
end
end


Line 598: Line 608:
             and config.CitationClass ~= "encyclopaedia"
             and config.CitationClass ~= "encyclopaedia"
         ) then
         ) then
             if Chapter:sub(1,1) == "'" then Chapter = "<span />" .. Chapter; end
             Chapter = "''" .. safeforitalics(Chapter) .. "''"
            if Chapter:sub(-1,-1) == "'" then Chapter = Chapter .. "<span />"; end
            Chapter = "''" .. Chapter .. "''"
         else
         else
             Chapter = "\"" .. Chapter .. "\""
             Chapter = "\"" .. Chapter .. "\""
Line 627: Line 635:
             Title = "\"" .. Title .. "\""
             Title = "\"" .. Title .. "\""
         else
         else
             if Title:sub(1,1) == "'" then Title = "<span />" .. Title; end
             Title = "''" .. safeforitalics(Title) .. "''"
            if Title:sub(-1,-1) == "'" then Title = Title .. "<span />"; end
           
            Title = "''" .. Title .. "''"
         end
         end
         Title = Title .. TransTitle
         Title = Title .. TransTitle
Line 810: Line 815:
         if ( LayDate ~= nil ) then LayDate = " (" .. LayDate .. ")" else LayDate = "" end
         if ( LayDate ~= nil ) then LayDate = " (" .. LayDate .. ")" else LayDate = "" end
         if ( LaySource ~= nil ) then  
         if ( LaySource ~= nil ) then  
            if LaySource:sub(1,1) == "'" then LaySource = "<span />" .. LaySource; end
             LaySource = " &ndash; ''" .. safeforitalics(LaySource) .. "''"  
            if LaySource:sub(-1,-1) == "'" then LaySource = LaySource .. "<span />"; end
 
             LaySource = " &ndash; ''" .. LaySource .. "''"  
         else  
         else  
             LaySource = ""  
             LaySource = ""  
Line 852: Line 854:
     -- Several of the above rely upon detecting this as nil, so do it last.
     -- Several of the above rely upon detecting this as nil, so do it last.
     if ( Periodical ~= nil and Periodical ~="" ) then  
     if ( Periodical ~= nil and Periodical ~="" ) then  
        if Periodical:sub(1,1) == "'" then Periodical = "<span />" .. Periodical; end
        if Periodical:sub(-1,-1) == "'" then Periodical = Periodical .. "<span />"; end
         if ( Title and Title ~= "") then  
         if ( Title and Title ~= "") then  
             Periodical = sepc .. " ''" .. Periodical .. "''"
             Periodical = sepc .. " ''" .. safeforitalics(Periodical) .. "''"
         else  
         else  
             Periodical = "''" .. Periodical .. "''"
             Periodical = "''" .. safeforitalics(Periodical) .. "''"
         end
         end
     else Periodical = "" end
     else Periodical = "" end
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.