Open main menu

Changes

Module:Citation

673 bytes removed, 22:15, 26 August 2012
Removed use of ipairs() directly on a template argument list. Eliminated function now in Module:Wikitext.
--require "mw.text"
local p = {} -- This can be removed when mw.text.tag appears.function tag(frame, t) local name = t.name or "!--" local content = t.contents or "" local params = "" if ( "nowiki" == name or "ref" == name or "pre" == name or "gallery" == name or "poem" == name ) then -- We have to preprocess these, so that they are properly turned into so-called "strip markers" in the generated wikitext. for n,v in pairs(t.params) do params = params .. require "|" .. n .. "=Module:Wikitext" .. v end return frame:preprocess("{{#tag:" .. name .. "|" .. content .. params .. "}}") else -- Everything else we can just generate directly, without calling the preprocessor. for n,v in pairs(t.params) do params = params .. " " .. n .. "=\"" .. v .. "\"" end return "<" .. name .. params .. ">" .. content .. "</" .. name .. ">" endend
function hideinprint(frame, content)
function doi(frame, id)
local text = hideinprint(frame, "[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:" .. id .. "}} " .. p.wikitext. tag(frame, {name="nowiki",contents=id,params={}}) .. "]")
if ( string.sub(id,1,3) ~= "10." ) then
text = text .. "[[Category:Pages with DOI errors]]"
end
local args = { class="citation " .. config.CitationClass, id=id }
text = p.wikitext.tag(frame, {name="span", contents=text, params=args})
end
return text
if ( page ~= nil ) then
local contents = ":" .. page
p = p.wikitext.tag(frame, {name="sup",contents=contents,params={class="reference",style="white-space:nowrap;"}})
end
return p.wikitext.tag(frame, {name="ref",contents="",params={name=name,group=group}}) .. p
end
local args = { name = refid(pframe.args) }
-- return mw.text.tag{name = "ref", contents = content, params = args}
return p.wikitext.tag(frame, {name = "ref", contents = content, params = args})
end
args.page1 = args.page1 or args.page
local text = ""
-- This would be shorter using ipairs(), but that doesn't work on an arguments table supplied to a template.
local index = 1
while args[index] ~= nil do
params.class="reference"
if ( args.noid ~= nil and args.noid ~= "" ) then params.id = "ref_" .. P1 .. P3 end
return p.wikitext.tag(frame, {name="sup",contents=contents,params=params})
end
return p
Anonymous user