Module:Citation/CS1: Difference between revisions

sync with sandbox. Fixes OrigYear with no Author, position of Series, and styling of cite web with Chapter. Changes default behavior of display-authors. Cleanup error message system.
m>Dragons flight
(sync with sandbox. Addresses format / type positioning, CITEREF encoding, and error categorization)
m>Dragons flight
(sync with sandbox. Fixes OrigYear with no Author, position of Series, and styling of cite web with Chapter. Changes default behavior of display-authors. Cleanup error message system.)
Line 517: Line 517:
     local LastAuthorAmp = args.lastauthoramp
     local LastAuthorAmp = args.lastauthoramp
     local no_tracking_cats = args["template doc demo"] or args.nocat or args.notracking or args["no-tracking"] or "";
     local no_tracking_cats = args["template doc demo"] or args.nocat or args.notracking or args["no-tracking"] or "";
     local MessageTail = "";
     local MessageTail = {};


     if ( config.CitationClass == "journal" ) then
     if ( config.CitationClass == "journal" ) then
Line 653: Line 653:
     -- We also add leading spaces and surrounding markup and punctuation to the various parts of the citation, but only when they are non-nil.
     -- We also add leading spaces and surrounding markup and punctuation to the various parts of the citation, but only when they are non-nil.
     if ( Authors == nil ) then  
     if ( Authors == nil ) then  
         local AuthorNameSep = args["author-name-separator"] or args["name-separator"] or ","
         local Maximum = tonumber(args["display-authors"] or args.displayauthors);
         AuthorNameSep = AuthorNameSep .. " "
       
         local AuthorSep = args["author-separator"] or ";"
        -- Preserve old-style implicit et al.
        AuthorSep = AuthorSep .. " "
         if Maximum == nil and #a == 9 then
        local AuthorFormat = args["author-format"] or args.authorformat
            Maximum = 8;
        local AuthorMaximum = tonumber(args["display-authors"] or args.displayauthors) or 8
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum, lastauthoramp = LastAuthorAmp }
            table.insert( MessageTail, 'Citation uses old-style implicit et al. for authors' );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
           
         local control = {
            sep = (args["author-separator"] or ";") .. " ",
            namesep = (args["author-name-separator"] or args["name-separator"] or ",") .. " ",
            format = args["author-format"] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
       
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= "" then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
               
         Authors = listpeople(control, a)  
         Authors = listpeople(control, a)  
     end
     end
     local EditorCount
     local EditorCount
     if ( Editors == nil ) then  
     if ( Editors == nil ) then  
         local EditorNameSep = args["editor-name-separator"] or args["name-separator"] or ","
         local Maximum = tonumber(args["display-editors"] or args.displayeditors);
         EditorNameSep = EditorNameSep .. " "
 
         local EditorSep = args["editor-separator"] or ";"
        -- Preserve old-style implicit et al.
        EditorSep = EditorSep .. " "
         if Maximum == nil and #e == 4 then
        local EditorFormat = args["editor-format"] or args.editorformat
            Maximum = 3;
        local EditorMaximum = tonumber(args["display-editors"] or args.displayeditors) or 3
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum, lastauthoramp = LastAuthorAmp }
            table.insert( MessageTail, 'Citation uses old-style implicit et al. for editors' );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end
 
         local control = {
            sep = (args["editor-separator"] or ";") .. " ",
            namesep = (args["editor-name-separator"] or args["name-separator"] or ",") .. " ",
            format = args["editor-format"] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }
 
         Editors, EditorCount = listpeople(control, e)  
         Editors, EditorCount = listpeople(control, e)  
     else
     else
Line 724: Line 754:
         if ( config.CitationClass == "web" ) then
         if ( config.CitationClass == "web" ) then
             table.insert( z.error_categories, 'Pages using web citations with no URL' );
             table.insert( z.error_categories, 'Pages using web citations with no URL' );
             if MessageTail ~= '' then
             table.insert( MessageTail, 'No URL on cite web' );
                MessageTail = MessageTail .. ", no URL on cite web";
            else
                MessageTail = MessageTail .. "No URL on cite web";
            end
         end
         end


Line 734: Line 760:
         if ( AccessDate ~= nil and AccessDate ~= '' ) then
         if ( AccessDate ~= nil and AccessDate ~= '' ) then
             table.insert( z.error_categories, 'Pages using citations with accessdate and no URL' );
             table.insert( z.error_categories, 'Pages using citations with accessdate and no URL' );
            table.insert( MessageTail, 'Accessdate used without URL' );
             AccessDate = nil;
             AccessDate = nil;
            if MessageTail ~= '' then
                MessageTail = MessageTail .. ", accessdate used without URL";
            else
                MessageTail = MessageTail .. "Accessdate used without URL";
            end
         end       
         end       
      
      
Line 755: Line 777:
             ( Conference == nil or Conference == "" ) then
             ( Conference == nil or Conference == "" ) then
         table.insert( z.error_categories, 'Pages with citations lacking titles' );
         table.insert( z.error_categories, 'Pages with citations lacking titles' );
         if MessageTail ~= '' then
         table.insert( MessageTail, 'Citation has no title' );
            MessageTail = MessageTail .. ", citation has no title";
        else
            MessageTail = MessageTail .. "Citation has no title";  
        end
     end
     end


Line 801: Line 819:
             Title = "\"" .. Title .. "\""
             Title = "\"" .. Title .. "\""
         elseif ( config.CitationClass == "web"
         elseif ( config.CitationClass == "web"
              or config.CitationClass == "news" ) then
                or config.CitationClass == "news" ) and
                Chapter == "" then
             Title = "\"" .. Title .. "\""
             Title = "\"" .. Title .. "\""
         else
         else
Line 1,064: Line 1,083:
         tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
         tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
     else  
     else  
         tcommon = safejoin( {Title, TitleNote, Series, Conference, Periodical, Format, TitleType, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
         tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
     end
     end
      
      
Line 1,118: Line 1,137:
         if ( "" ~= Date ) then
         if ( "" ~= Date ) then
             if ( string.sub(tcommon,-1,-1) ~= sepc )
             if ( string.sub(tcommon,-1,-1) ~= sepc )
               then Date = sepc .." " .. Date
               then Date = sepc .." " .. Date .. OrigYear
               else Date = " " .. Date
               else Date = " " .. Date .. OrigYear
             end
             end
         end -- endif ""~=Date
         end -- endif ""~=Date
Line 1,181: Line 1,200:
         z.error_categories = { 'Pages with empty citations' };
         z.error_categories = { 'Pages with empty citations' };
         text = '<span class="error">Citation is empty</span>';
         text = '<span class="error">Citation is empty</span>';
         MessageTail = '';
         MessageTail = {};
     end
     end
      
      
Line 1,192: Line 1,211:
     text = text .. OCinS;
     text = text .. OCinS;
      
      
     if MessageTail ~= '' then
     if #MessageTail ~= 0 then
         text = text .. hiddencomment( MessageTail );
         text = text .. hiddencomment( table.concat( MessageTail, "; " ) );
     end
     end
      
      
Anonymous user