Jump to content

Module:Citation/CS1: Difference between revisions

convert extractauthor to extractauthors, etc., less coping of parameters back and forth. Possibly better for performance.
m>Dragons flight
(formatting and comments)
m>Dragons flight
(convert extractauthor to extractauthors, etc., less coping of parameters back and forth. Possibly better for performance.)
Line 301: Line 301:
     return LB .. "[[" .. pagename .. "#" .. anchor .. "|" .. text .. "]]" .. loc .. RB .. ps
     return LB .. "[[" .. pagename .. "#" .. anchor .. "|" .. text .. "]]" .. loc .. RB .. ps
end
end
 
   
function extractauthor(args, i)
function extractauthors(args)
     local last = args["author" .. i .. "-last"] or args["author-last" .. i] or args["last" .. i] or args["surname" .. i] or args["Author" .. i] or args["author" .. i]
    local authors = {};
    if ( last and "" < last ) then -- just in case someone passed in an empty parameter
    local i = 1;
        return {
     local last;
            last = last,
   
            first = args["author" .. i .. "-first"] or args["author-first" .. i] or args["first" .. i] or args["given" .. i],
    while true do
            link = args["author" .. i .. "-link"] or args["author-link" .. i] or args["author" .. i .. "link"] or args["authorlink" .. i],
        last = args["author" .. i .. "-last"] or args["author-last" .. i] or args["last" .. i] or args["surname" .. i] or args["Author" .. i] or args["author" .. i]
            mask = args["author" .. i .. "-mask"] or args["author-mask" .. i] or args["author" .. i .. "mask"] or args["authormask" .. i]
        if ( last and "" < last ) then -- just in case someone passed in an empty parameter
        }
            authors[i] = {
    else
                last = last,
         return nil
                first = args["author" .. i .. "-first"] or args["author-first" .. i] or args["first" .. i] or args["given" .. i],
                link = args["author" .. i .. "-link"] or args["author-link" .. i] or args["author" .. i .. "link"] or args["authorlink" .. i],
                mask = args["author" .. i .. "-mask"] or args["author-mask" .. i] or args["author" .. i .. "mask"] or args["authormask" .. i]
            }
        else
            break;
         end
        i = i + 1;
     end
     end
    return authors;
end
end


function extracteditor(args, i)
function extracteditors(args)
     local last = args["editor" .. i .. "-last"] or args["editor-last" .. i] or args["EditorSurname" .. i] or args["Editor" .. i] or args["editor" .. i]
    local editors;
    if ( last and "" < last ) then -- just in case someone passed in an empty parameter
    local i = 1;
        return {
    local last;
            last = last,
   
            first = args["editor" .. i .. "-first"] or args["editor-first" .. i] or args["EditorGiven" .. i],
     while true do
            link = args["editor" .. i .. "-link"] or args["editor-link" .. i] or args["editor" .. i .. "link"] or args["editorlink" .. i],
        local last = args["editor" .. i .. "-last"] or args["editor-last" .. i] or args["EditorSurname" .. i] or args["Editor" .. i] or args["editor" .. i]
            mask = args["editor" .. i .. "-mask"] or args["editor-mask" .. i] or args["editor" .. i .. "mask"] or args["editormask" .. i]
        if ( last and "" < last ) then -- just in case someone passed in an empty parameter
        }
            editors[i] = {
    else
                last = last,
         return nil
                first = args["editor" .. i .. "-first"] or args["editor-first" .. i] or args["EditorGiven" .. i],
                link = args["editor" .. i .. "-link"] or args["editor-link" .. i] or args["editor" .. i .. "link"] or args["editorlink" .. i],
                mask = args["editor" .. i .. "-mask"] or args["editor-mask" .. i] or args["editor" .. i .. "mask"] or args["editormask" .. i]
            }
        else
            break;
        end
         i = i + 1;
     end
     end
    return editors;
end
end


Line 359: Line 375:
     local Authors = args.authors
     local Authors = args.authors
     local i  
     local i  
     local a = {}
     local a = extractauthors( args );
    i = 1
 
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
     local Coauthors = args.coauthors or args.coauthor  
     local Coauthors = args.coauthors or args.coauthor  
     local Others = args.others  
     local Others = args.others  
Line 371: Line 382:
     local EditorFormat = args["editor-format"] or args.editorformat
     local EditorFormat = args["editor-format"] or args.editorformat
     local Editors = args.editors
     local Editors = args.editors
     local e = {}
     local e = extracteditors( args );
    i = 1
 
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
     local Year = args.year  
     local Year = args.year  
     local PublicationDate = args.publicationdate or args["publication-date"]
     local PublicationDate = args.publicationdate or args["publication-date"]
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.