Open main menu

Changes

Module:Citation

2,206 bytes added, 19:11, 27 August 2012
Added processing of more parameters.
-- Pick out the relevant fields from the arguments. Different citation templates define different field names for the same underlying things.
local AuthorMask = args.authormask or args.authormask
local Authors = args.authors
local i
local a = {}
i = 1
while true do
local last = args["last" .. i] or args["surname" .. i] or args["Author" .. i] or args["author" .. i]
if ( last ~= nil ) then
a[i] = {}
if ( a[1] == nil ) then
local i = ""
local last = args["last" .. i] or args["surname" .. i] or args["Author" .. i] or args["author" .. i]
if ( last ~= nil ) then
a[1] = {}
end
end
local Coauthors = args.coauthors or args.coauthor or local Others = args.coauthors others local Editors = args.editors
local e = {}
i = 1
while true do
local last = args["editor" .. i .. "-last"] or args["editor-last" .. i] or args["EditorSurname" .. i] or args["Editor" .. i] or args["editor" .. i]
if ( last ~= nil ) then
e[i] = {}
if ( e[1] == nil ) then
local i = ""
local last = args["editor" .. i .. "-last"] or args["editor-last" .. i] or args["EditorSurname" .. i] or args["Editor" .. i] or args["editor" .. i]
if ( last ~= nil ) then
e[1] = {}
end
end
local Year = args.year or local PublicationDate = args.publicationdate local OrigYear = args.origyear
local Date = args.date
local Title = args.title or args.encyclopaedia or args.encyclopedia
local TransTitle = args.trans_title
local Chapter = args.chapter or args.article
local TransChapter = args.trans_chapter
local Type = args.type
local URL = args.archiveurl or args.url
local ChapterURL = args.chapterurl
local Periodical = args.journal or args.newspaper or args.magazine or args.workor args.periodical
local Series = args.series
local Volume = args.volume
local Issue = args.issue or args.number
local Page = args.page local Pages = args.pages or local At = args.pageat
local Edition = args.edition
local Place = args.place or args.location
local PublicationPlace = args.publicationplace or args.place or args.location
local Publisher PublisherName = args.publisher
local SubscriptionRequired = args.subscription
local Via = args.via
local BIBCODE = args.bibcode or args.BIBCODE
local DOI = args.doi or args.DOI
local DoiBroken = args.doi_brokendate or args.DoiBroken
local ID = args.id or args.ID
local ISBN = args.isbn or args.ISBN
if ( nil ~= Title ) then OCinSdata["rft.btitle"] = Title end
end
if ( PublicationPlace or Place ) then OCinSdata["rft.place"] = (PublicationPlace or Place) end OCinSdata["rft.date"] = Dateor Year or PublicationDate
OCinSdata["rft.series"] = Series
OCinSdata["rft.volume"] = Volume
OCinSdata["rft.issue"] = Issue
OCinSdata["rft.pages"] = Page or Pages or At
OCinSdata["rft.edition"] = Edition
OCinSdata["rft.pub"] = PublisherPublisherName
OCinSdata["rft.isbn"] = ISBN
OCinSdata["rft.issn"] = ISSN
OCinSdata["rft.lccn"] = LCCN
OCinSdata["rft.mr"] = MR
OCinSdata.rft_id = (URL or ChapterURL)
if ( nil ~= a[1] and nil ~= a[1].last) then
local last = a[1].last
if ( args.day ~= nil ) then Date = args.day .. " " .. Date end
end
end end if ( Periodical ~= nil ) then Chapter = Title Title = Periodical
end
if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
if ( Chapter ~= nil ) then
if ( Periodical ~= nil ) then Chapter = "\"" .. Chapter .. "\"" else Chapter = "''" .. Chapter .. "''" end
if ( ChapterURL ~= nil ) then
Chapter = "[" .. ChapterURL .. " " .. Chapter .. "]"
URL = nil
end
if ( Periodical ~= nil ) then Title = " ''" .. Title .. "''." else Title = " \"" .. Title .. "\"." end
else
Title = ""
end
if ( Publisher nil == Page ) then Page = "" elseif ( Periodical ~= nil ) then Page = " :" .. Page elseif ( "y" == args.nopp ) then Page = " " .. Page else Page = " p." .. Page end if ( nil == Pages ) then Pages = "" elseif ( Periodical ~= nil ) then Pages = " :" .. Page elseif ( "y" == args.nopp ) then Pages = " " .. Pages else Pages = " pp." .. Page end if ( At ~= nil ) then At = " " .. At .. "." else At = "" end if ( Coauthors ~= nil ) then Coauthors = " " .. Coauthors .. "." else Coauthors = "" end if ( Others ~= nil ) then Publisher Others = " " .. Publisher Others .. "." else Publisher Others = "" end if ( PublicationPlace TransTitle ~= nil ) then TransTitle = " (" .. TransTitle .. ")." else TransTitle = "" end if ( TransChapter ~= nil ) then TransChapter = " (" .. TransChapter .. ")." else TransChapter = "" end if ( Type ~= nil ) then PublicationPlace Type = " (" .. Type .. ")." else Type = "" end if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. ":" else PublicationPlace = "" end
if ( Language ~= nil ) then Language = " (in " .. Language .. ")" else Language = "" end
if ( Edition ~= nil ) then Edition = " (" .. Edition .. " edition)" else Edition = "" end
if ( Volume ~= nil ) then Volume = " '''" .. Volume .. "'''" else Volume = "" end
if ( Issue ~= nil ) then Issue = " (" .. Issue .. ")" else Issue = "" end
if ( Pages ~= nil ) then Pages = " :" .. Pages else Pages = "" end
if ( Series ~= nil ) then Series = " " .. Series .. "." else Series = "" end
if ( Format ~= nil ) then Format = " (" .. Format .. ")" else Format = "" end
if ( OrigYear ~= nil ) then OrigYear = " " .. OrigYear else OrigYear = "" end
if ( Date ~= nil ) then Date = " (" .. Date .. ")" else Date = "" end
if ( Via ~= nil ) then Via = " — via " .. Via else Via = "" end
if ( URL ~= nil ) then URL = " " .. url(frame, URL) else URL = "" end
if ( ZBL ~= nil ) then ZBL = " " .. externallinkid(frame, {label="ZBL",link="Zentralblatt MATH",prefix="http://www.zentralblatt-math.org/zmath/en/search/?format=complete&q=an:",id=ZBL}) else ZBL = "" end
local Publisher
if ( Periodical ~= nil ) then
if ( PublicationDate ~= nil ) then PublicationDate = " " .. PublicationDate else PublicationDate = "" end
if ( PublisherName ~= nil ) then Publisher = "(" .. PublicationPlace .. PublisherName .. PublicationDate .. ")." else Publisher = "" end
Edition = ""
else
if ( PublicationDate ~= nil ) then PublicationDate = " (published " .. PublicationDate .. ")" else PublicationDate = "" end
if ( PublisherName ~= nil ) then Publisher = " " .. PublicationPlace .. PublisherName .. PublicationDate .. "." else Publisher = "" end
end
-- Several of the above rely upon detecting this as nil, so do it last.
if ( Periodical ~= nil ) then Periodical = " " .. Periodical .. "." else Periodical = "" end
-- Piece all of the bits together at last. At this point, all of these should be guaranteed 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.
local common idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages Date = Date .. OrigYear
local text
if ( "" ~= Authors ) then
if ( "" ~= Date ) then Date = Date .. "." else Authors = Authors .. "." end
if ( "" ~= Editors ) then Editors = " in " .. Editors .. "." end
text = Authors .. Coauthors .. Date .. Chapter .. Editors TransChapter .. Title Others .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series Editors .. PublicationPlace tcommon .. Publisher .. commonidcommon
elseif ( "" ~= Editors) then
Editors = Editors .. " (eds.)"
if ( "" ~= Date ) then Date = Date .. "." else Editors = Editors .. "." end
text = Editors .. Date .. Chapter .. Title TransChapter .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace tcommon .. Publisher .. commonidcommon
else
text = Chapter .. Title TransChapter .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace tcommon .. Publisher .. Date .. common
end
Anonymous user