Changes

Jump to navigation Jump to search

Module:Citation

822 bytes added, 20:50, 25 August 2012
Added commentary and code to prevent missing years generating punctuation.
function citation0(frame, args)
local config = frame.args
-- 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 Surname1 = args.last or args.surname or args.author or args.last1 or args.surname1 or args.author1
local Authorlink9 = args.author9link or args.authorlink9
local Coauthors = args.coauthor or args.coauthors
local Year = args.year or args.publicationdate or ""
local Date = args.date
local Title = args.title or args.encyclopedia
local Editors = args.editors
local Ref = args.ref or args.Ref
-- At this point fields may be nil if they weren't specified in the template use. We can use that to perform various substitutions.
-- 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 ( Date == nil ) then
Date = Year
Editors = ""
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 text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL -- Now enclose the whole thing in a <span/> element if it is cross-linked from elsewhere. if ( Year == nil ) then Year = "" end
if ( Ref ~= nil ) then
local id = Ref
Anonymous user

Navigation menu