Module:Citation/CS1: Difference between revisions
merge from sandbox. Removes unused functions (moved to Module:Citation) and updates page handling
m>Dragons flight (remove Module:Wikitext requirement no longer used here, and remove parts of createTag no longer needed) |
m>Dragons flight (merge from sandbox. Removes unused functions (moved to Module:Citation) and updates page handling) |
||
Line 20: | Line 20: | ||
['&'] = '&', | ['&'] = '&', | ||
["'"] = ''', | ["'"] = ''', | ||
['['] = '[', | ['['] = '[', | ||
[']'] = ']', | [']'] = ']', | ||
['{'] = '{', | ['{'] = '{', | ||
Line 140: | Line 140: | ||
function hyphentodash( str ) | function hyphentodash( str ) | ||
if str == nil then | |||
return nil; | |||
end | |||
return str:gsub( '-', '–' ); | return str:gsub( '-', '–' ); | ||
end | end | ||
Line 302: | Line 305: | ||
end | end | ||
function extractauthors(args) | function extractauthors(args) | ||
local authors = {}; | local authors = {}; | ||
Line 477: | Line 425: | ||
local Issue = args.issue or args.number | local Issue = args.issue or args.number | ||
local Position = nil | local Position = nil | ||
local Page | local Page = args.p or args.page | ||
local Pages = args.pages | local Pages = hyphentodash( args.pp or args.pages ) | ||
if Pages == | local At = args.at | ||
local page_error = false; | |||
Pages = | if Page ~= nil and Page ~= '' then | ||
end | if (Pages ~= nil and Pages ~= '') or (At ~= nil and At ~= '') then | ||
Pages = nil; | |||
At = nil; | |||
page_error = true; | |||
end | |||
elseif Pages ~= nil and Pages ~= '' then | |||
if At ~= nil and At ~= '' then | |||
At = nil; | |||
page_error = true; | |||
end | |||
end | |||
local PP = args.pp | local PP = args.pp | ||
local Edition = args.edition | local Edition = args.edition | ||
local PublicationPlace = args["publication-place"] or args.publicationplace or args.place or args.location | local PublicationPlace = args["publication-place"] or args.publicationplace or args.place or args.location | ||
Line 792: | Line 749: | ||
if ( nil == Page or "" == Page ) then | if ( nil == Page or "" == Page ) then | ||
Page = "" | Page = "" | ||
if ( nil == Pages or "" == Pages) then | |||
Pages = "" | |||
elseif ( Periodical ~= nil and Periodical ~= "" and | |||
config.CitationClass ~= "encyclopaedia" and | |||
config.CitationClass ~= "web" and | |||
config.CitationClass ~= "book" and | |||
config.CitationClass ~= "news") then | |||
Pages = ": " .. Pages | |||
else | |||
if ( tonumber(Pages) ~= nil ) then | |||
Pages = sepc .." " .. PPrefix .. Pages | |||
else Pages = sepc .." " .. PPPrefix .. Pages | |||
end | |||
end | |||
else | else | ||
Pages = "" | |||
if ( Periodical ~= nil and Periodical ~= "" and | |||
config.CitationClass ~= "encyclopaedia" and | config.CitationClass ~= "encyclopaedia" and | ||
config.CitationClass ~= "web" and | config.CitationClass ~= "web" and | ||
config.CitationClass ~= "book" and | config.CitationClass ~= "book" and | ||
config.CitationClass ~= "news") then | config.CitationClass ~= "news") then | ||
Page = ": " .. Page | |||
else | |||
Page = sepc .." " .. PPrefix .. Page | |||
end | end | ||
end | end | ||
Line 1,008: | Line 968: | ||
local text | local text | ||
local pgtext = Page .. Pages .. At | local pgtext = Page .. Pages .. At | ||
if page_error then | |||
pgtext = pgtext .. '[[Category:References with multiple page specifications]]<!-- Bad page specification here -->'; | |||
end | |||
if ( "" ~= Authors ) then | if ( "" ~= Authors ) then | ||
if (Coauthors ~= "") | if (Coauthors ~= "") | ||
Line 1,224: | Line 1,188: | ||
--14Mar2013 Fixed double-dot before "p." or "pp." page number. | --14Mar2013 Fixed double-dot before "p." or "pp." page number. | ||
--14Mar2013 Fixed config.CitationClass "book" to use p./pp. page. | --14Mar2013 Fixed config.CitationClass "book" to use p./pp. page. | ||
--18Mar2013 Fixed "page=" to override "pages=" as in markup-based cites. | |||
-- | -- | ||
--End | --End |