Module:Citation/CS1: Difference between revisions

reworked to stop double-dots "..", put NOTES comments to explain module operation.
m>Wikid77
(fixed dot "." when Publisher & omit parentheses "(publisher)" if CitationClass "web" etc.)
m>Wikid77
(reworked to stop double-dots "..", put NOTES comments to explain module operation.)
Line 587: Line 587:
     if ( Volume ~= nil ) then Volume = " <b>" .. Volume .. "</b>" else Volume = "" end
     if ( Volume ~= nil ) then Volume = " <b>" .. Volume .. "</b>" else Volume = "" end
     if ( Issue ~= nil ) then Issue = " (" .. Issue .. ")" else Issue = "" end
     if ( Issue ~= nil ) then Issue = " (" .. Issue .. ")" else Issue = "" end
     if ( Series ~= nil ) then Series = " " .. Series .. "." else Series = "" end
     if ( Series ~= nil ) then Series = ". " .. Series else Series = "" end
     if ( Format ~= nil ) then Format = " (" .. Format .. ")" else Format = "" end
     if ( Format ~= nil ) then Format = " (" .. Format .. ")" else Format = "" end
     if ( OrigYear ~= nil ) then OrigYear = " [" .. OrigYear .. "]" else OrigYear = "" end
     if ( OrigYear ~= nil ) then OrigYear = " [" .. OrigYear .. "]" else OrigYear = "" end
     if ( Agency ~= nil ) then Agency = " " .. Agency .. "." else Agency = "" end
     if ( Agency ~= nil ) then Agency = ". " .. Agency else Agency = "" end
    ------------------------------------ totally unrelated data
     if ( Date ~= nil ) then Date = Date else Date = "" end
     if ( Date ~= nil ) then Date = Date else Date = "" end
     if ( Via ~= nil ) then Via = " &mdash; via " .. Via else Via = "" end
     if ( Via ~= nil ) then Via = " &mdash; via " .. Via .. "." else Via = "" end
     if ( AccessDate ~= nil ) then AccessDate = " Retrieved " .. AccessDate .. "." else AccessDate = "" end
     if ( AccessDate ~= nil ) then AccessDate = " Retrieved " .. AccessDate .. "." else AccessDate = "" end
     if ( SubscriptionRequired ~= nil ) then
     if ( SubscriptionRequired ~= nil ) then
Line 656: Line 657:
         if ( PublicationDate ~= nil ) then PublicationDate = " " .. PublicationDate else PublicationDate = "" end
         if ( PublicationDate ~= nil ) then PublicationDate = " " .. PublicationDate else PublicationDate = "" end
         if ( PublisherName ~= nil ) then
         if ( PublisherName ~= nil ) then
             Publisher = " (" .. PublicationPlace .. PublisherName .. PublicationDate .. ")."
             Publisher = " (" .. PublicationPlace .. PublisherName .. PublicationDate .. ")"
         else
         else
             if (Location ~=nil) then Publisher= " (" .. Location .. ")."
             if (Location ~=nil) then Publisher= " (" .. Location .. ")"
             else Publisher = "" end
             else Publisher = "" end
         end
         end
Line 664: Line 665:
     else
     else
         if ( PublicationDate ~= nil ) then PublicationDate = " (published " .. PublicationDate .. ")" else PublicationDate = "" end
         if ( PublicationDate ~= nil ) then PublicationDate = " (published " .. PublicationDate .. ")" else PublicationDate = "" end
         if ( PublisherName ~= nil ) then Publisher = ". " .. PublicationPlace .. PublisherName .. PublicationDate .. "." else Publisher = "" end
         if ( PublisherName ~= nil ) then Publisher = ". " .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = "" end
     end
     end
     -- 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.
    local enddot = ""
     if ( Periodical ~= nil ) then  
     if ( Periodical ~= nil ) then  
         Periodical = " <i>" .. Periodical .. "</i>"
         Periodical = ". <i>" .. Periodical .. "</i>"
        if ( Publisher == "" ) then Publisher = "." end
     else Periodical = "" end
     else Periodical = "" end
      
      
     -- Piece all bits together at last.  At this point, all should be non-nil.
     -- Piece all bits together at last.  At this point, all should be non-nil.
     -- We build things this way because it is more efficient in LUA not to keep reassigning to the same string variable over and over.
     -- We build things this way because it is more efficient in LUA not to keep reassigning to the same string variable over and over.
     local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
     local enddot = "."
    local endtitle = "."
     if (Title == "")
     if (Title == "")
     then endtitle = "" end
     then enddot = "" end
     local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. endtitle .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Position
     local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Position .. enddot
     -- DEBUG: tcommon = "/Title="..Title .. "/TitleType="..TitleType .. "/TitleNote="..TitleNote .. "/Format="..Format .. "/Edition="..Edition .. "/Language="..Language .. "/Conference="..Conference .. "/Periodical="..Periodical .. "/Series="..Series .. "/Volume="..Volume .. "/Issue="..Issue .. "/Position="..Position
     -- DEBUG: tcommon = "/Title="..Title .. "/TitleType="..TitleType .. "/TitleNote="..TitleNote .. "/Format="..Format .. "/Edition="..Edition .. "/Language="..Language .. "/Conference="..Conference .. "/Periodical="..Periodical .. "/Series="..Series .. "/Volume="..Volume .. "/Issue="..Issue .. "/Position="..Position
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript


     local text
     local text
Line 694: Line 693:
         text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
         text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
     else
     else
         if ( "" ~= Date ) then Date = " " .. Date .. "." end
         if ( "" ~= Date ) then Date = Date .. "." end
         text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
         text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
     end
     end
Line 953: Line 952:


return z
return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses "(data)". There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots ".." in some cases.
--
------------------------------------------------------------------------
------------------------------------------------------------------------
--HISTORY:
--HISTORY:
Line 961: Line 976:
--19Oct2012 For pages, put &nbsp in "p.&nbsp;" etc.
--19Oct2012 For pages, put &nbsp in "p.&nbsp;" etc.
--19Oct2012 Enhanced "pages=" to detect lone page as "p." else "pp." prefix.
--19Oct2012 Enhanced "pages=" to detect lone page as "p." else "pp." prefix.
--19Oct2012 Fixed to show "." after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed to show "." after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces "[...  Archived] from the original".
--19Oct2012 Fixed web-link to have spaces "[...  Archived] from the original".
--19Oct2012 Fixed to show ";" between authors & coauthors.
--19Oct2012 Fixed to show ";" between authors & coauthors.
--19Oct2012 Fixed to omit "." after coauthors.
--19Oct2012 Fixed to omit extra "." after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as "ctx_ver=Z39.88-2004"
--20Oct2012 Fixed COinS data to not urlencode all, as "ctx_ver=Z39.88-2004"
--20Oct2012 Fixed COinS to not end as "&" but use lead "&rft...=" form.
--20Oct2012 Fixed COinS to not end as "&" but use lead "&rft...=" form.
Line 971: Line 986:
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for "agency=xx".
--15Feb2013 Added Agency for "agency=xx".
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--
--
--End
--End
Anonymous user