https://de.wikipedia.org/w/index.php?action=history&feed=atom&title=Modul%3ACitationModul:Citation - Versionsgeschichte2025-04-30T13:10:34ZVersionsgeschichte dieser Seite in WikipediaMediaWiki 1.44.0-wmf.25https://de.wikipedia.org/w/index.php?title=Modul:Citation&diff=117555091&oldid=prevFlorentyna: AZ: Die Seite wurde neu angelegt: --------------------------------------------------------------------- -- Module:Citation - Lua module …2013-04-15T17:31:13Z<p><a href="/wiki/Hilfe:Zusammenfassung_und_Quellen#Auto-Zusammenfassung" title="Hilfe:Zusammenfassung und Quellen">AZ</a>: Die Seite wurde neu angelegt: --------------------------------------------------------------------- -- Module:Citation - Lua module …</p>
<p><b>Neue Seite</b></p><div>---------------------------------------------------------------------<br />
-- Module:Citation - Lua module for Citation auxillary templates<br />
---------------------------------------------------------------------<br />
-- For the {{citation}} formatting functions, see: Module:Citation/CS1<br />
-- (see NOTES at bottom)<br />
--require "mw.text"<br />
<br />
local z = {<br />
wikitext = require("Module:Wikitext"),<br />
extensiontags = {<br />
nowiki = true,<br />
ref = true,<br />
gallery = true,<br />
pre = true,<br />
source = true,<br />
categorytree = true,<br />
charinsert = true,<br />
hiero = true,<br />
imagemap = true,<br />
inputbox = true,<br />
math = true,<br />
poem = true,<br />
ref = true,<br />
references = true,<br />
syntaxhighlight = true,<br />
timeline = true,<br />
}<br />
}<br />
<br />
function trim( str )<br />
if str == nil then<br />
return nil;<br />
end<br />
return str:match( "^%s*(.-)%s*$" );<br />
end<br />
<br />
function hideinprint(content)<br />
return content<br />
end<br />
<br />
function onlyinprint(content)<br />
return ""<br />
end<br />
<br />
-- This returns a string with HTML character entities for wikitext markup characters.<br />
function wikiescape(text)<br />
text = text:gsub( '[&\'%[%]{|}]', { <br />
['&'] = '&#38;', <br />
["'"] = '&#39;', <br />
['['] = '&#91;', <br />
[']'] = '&#93;', <br />
['{'] = '&#123;', <br />
['|'] = '&#124;', <br />
['}'] = '&#125;' } );<br />
return text;<br />
end<br />
<br />
function createTag(t, frame)<br />
local name = t.name or "!-- --"<br />
local content = t.contents or ""<br />
local attrs = {}<br />
if ( z.extensiontags[name] ) then<br />
-- We have to preprocess these, so that they are properly turned into so-called "strip markers" in the generated wikitext.<br />
if ( not frame ) then error ("Please supply an extra frame argument to the createTag() function.") end<br />
local params = {}<br />
for n,v in pairs(t.params) do<br />
table.insert(params, "|" .. n .. "=" .. v)<br />
end<br />
return frame:preprocess("{{#tag:" .. name .. "|" .. content .. table.concat(params) .. "}}")<br />
else <br />
for n,v in pairs(t.params) do<br />
if (v) then<br />
table.insert(attrs, n .. "=\"" .. wikiescape(v) .. "\"")<br />
else<br />
table.insert(attrs, n)<br />
end<br />
end<br />
if ("" == content) then<br />
return "<" .. name .. " " .. table.concat(attrs, " ") .. "/>"<br />
else<br />
return "<" .. name .. " " .. table.concat(attrs, " ") .. ">" .. content .. "</" .. name .. ">"<br />
end<br />
end<br />
end<br />
<br />
--[[<br />
This is a clone of mw.text.nowiki. When the mw.text library is installed,<br />
this can be replaced by a call to that library. ]]<br />
function nowiki( s )<br />
-- string.gsub is safe here, because we're only caring about ASCII chars<br />
s = string.gsub( s, '["&\'<=>%[%]{|}]', {<br />
['"'] = '&#34;',<br />
['&'] = '&#38;',<br />
["'"] = '&#39;',<br />
['<'] = '&#60;',<br />
['='] = '&#61;',<br />
['>'] = '&#62;',<br />
['['] = '&#91;',<br />
[']'] = '&#93;',<br />
['{'] = '&#123;',<br />
['|'] = '&#124;',<br />
['}'] = '&#125;',<br />
} )<br />
s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {<br />
["\n#"] = "\n&#35;",<br />
["\n*"] = "\n&#42;",<br />
["\n:"] = "\n&#58;",<br />
["\n;"] = "\n&#59;",<br />
} ), 2 )<br />
s = string.gsub( s, '://', '&#58;//' )<br />
s = string.gsub( s, 'ISBN ', 'ISBN&#32;' )<br />
s = string.gsub( s, 'RFC ', 'RFC&#32;' )<br />
<br />
return s<br />
end<br />
<br />
function externallinkid(args)<br />
local sep = args.separator or "&nbsp;"<br />
args.suffix = args.suffix or ""<br />
local url_string = args.id<br />
if args.encode == true or args.encode == nil then<br />
url_string = mw.uri.encode( url_string );<br />
end<br />
<br />
local t0 = onlyinprint(args.label .. sep .. args.id)<br />
local t1 = hideinprint("[[" .. args.link .. "|" .. args.label .. "]]" .. sep .. "[" .. args.prefix .. url_string .. args.suffix .. " " .. nowiki(args.id) .. "]")<br />
<br />
return t0 .. t1<br />
end<br />
<br />
function doi(id, inactive, nocat)<br />
local cat = ""<br />
local text;<br />
if ( inactive ~= nil ) then <br />
text = "[[Digital object identifier|doi]]:" .. id;<br />
cat = cat .. "[[Category:Pages with DOIs inactive since " .. selectyear(inactive) .. "]]"<br />
inactive = " (inactive " .. inactive .. ")" <br />
else <br />
text = externallinkid({link="Digital object identifier",label="doi",prefix="http://dx.doi.org/",id=id,separator=":"})<br />
inactive = "" <br />
end<br />
if ( string.sub(id,1,3) ~= "10." ) then<br />
cat = cat .. "[[Category:Pages with DOI errors]]" .. '<span class="error"> Bad DOI (expected "10." prefix) in code number</span>'<br />
end<br />
if ( nocat and nocat ~= "" ) then cat = "" end<br />
return text .. inactive .. cat <br />
end<br />
<br />
function selectyear( str )<br />
local lang = mw.getContentLanguage();<br />
local good, result;<br />
good, result = pcall( lang.formatDate, lang, 'Y', str )<br />
if good then <br />
return result;<br />
else<br />
return '';<br />
end<br />
end<br />
<br />
function anchorid(label, args)<br />
local P1 = trim(args[1]) or ""<br />
local P2 = trim(args[2]) or ""<br />
local P3 = trim(args[3]) or ""<br />
local P4 = trim(args[4]) or ""<br />
local P5 = trim(args[5]) or ""<br />
local anchor = P1 .. P2 .. P3 .. P4 .. P5;<br />
if anchor ~= '' then -- See bug description in Citation/CS1<br />
anchor = mw.uri.anchorEncode( anchor );<br />
end<br />
<br />
return label .. anchor<br />
end<br />
<br />
function refid(label, args)<br />
local p = args.p or ""<br />
local pp = args.pp or ""<br />
local loc = args.loc or ""<br />
return anchorid(label, args) .. p .. pp .. loc <br />
end<br />
<br />
function name(args)<br />
local P1 = trim(args[1]) or ""<br />
if ( args[5] ~= nil) then<br />
return P1 .. " et al."<br />
else<br />
local P2 = trim(args[2]) or ""<br />
local P3 = trim(args[3]) or "" <br />
local P4 = trim(args[4]) or ""<br />
if ( args[4] ~= nil ) then<br />
P4 = " " .. P4<br />
P3 = " &amp; " .. P3<br />
P2 = ", " .. P2<br />
elseif ( args[3] ~= nil ) then<br />
P3 = " " .. P3<br />
P2 = " &amp; " .. P2<br />
elseif ( args[2] ~= nil ) then<br />
P2 = " " .. P2 <br />
end<br />
return P1 .. P2 .. P3 .. P4<br />
end <br />
end<br />
<br />
function crossref(frame, label, args)<br />
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself<br />
local LB = config.BracketLeft or ""<br />
local RB = config.BracketRight or ""<br />
local anchor = args.ref or args.Ref or anchorid( label, args)<br />
local text = name(args)<br />
local loc = args.loc<br />
local page<br />
local pages = args.pp or args.pages<br />
if pages == nil or pages == '' then<br />
page = args.p or args.page;<br />
end <br />
if nil == loc then loc = "" else loc = " " .. loc end<br />
if ( page ~= nil ) then<br />
local pagesep = config.PageSep or ", p.&nbsp;"<br />
loc = loc .. pagesep .. page<br />
end<br />
if ( pages ~= nil ) then<br />
local pagessep = config.PagesSep or ", pp.&nbsp;"<br />
loc = loc .. pagessep .. pages<br />
end <br />
local pagename = args.pagename or ""<br />
local ps = args.Postscript or ""<br />
return LB .. "[[" .. pagename .. "#" .. anchor .. "|" .. text .. "]]" .. loc .. RB .. ps<br />
end<br />
<br />
function r0(frame, name, group, page)<br />
if ( name == nil ) then return "" end<br />
if ( group == nil ) then group = "" end<br />
local p = ""<br />
if ( page ~= nil ) then <br />
local contents = ":" .. page<br />
p = createTag({name="sup",contents=contents,params={class="reference",style="white-space:nowrap;"}}) <br />
end<br />
return createTag({name="ref",contents="",params={name=name,group=group}}, frame) .. p<br />
end<br />
<br />
function reflist0(frame, config, args)<br />
local contents = args.refs or ""<br />
local liststyle = args.liststyle<br />
local count = args[1]<br />
local width = args.colwidth<br />
local group = args.group or config.default_group<br />
if ( nil == tonumber(count) and nil == width ) then <br />
width = count<br />
count = nil<br />
end<br />
if ( nil == liststyle ) then<br />
if ( "upper-alpha" == group or "lower-alpha" == group or "upper-roman" == group or "lower-roman" == group or "upper-greek" == group or "lower-greek" == group ) then<br />
liststyle = group<br />
else<br />
liststyle = config.default_liststyle<br />
end<br />
end<br />
local params = {}<br />
params.class = "reflist" <br />
params.style = z.wikitext.liststyle(liststyle)<br />
if ( nil ~= count ) then <br />
params.class = params.class .. " references-column-count references-column-count-" .. count<br />
params.style = params.style .. " " .. z.wikitext.columncountstyle(count)<br />
end <br />
if ( nil ~= width ) then<br />
params.class = params.class .. " references-column-width"<br />
params.style = params.style .. " " .. z.wikitext.columnwidthstyle(width)<br />
end<br />
local references = createTag({name="references",contents=contents,params={group=group}}, frame)<br />
return createTag({name="div",contents=references,params=params})<br />
end<br />
<br />
function refbegin0(frame, config, args)<br />
local liststyle = args.liststyle<br />
local indent = args.indent<br />
local indentsize = args.indentsize<br />
local count = args[1]<br />
local width = args.colwidth<br />
if ( nil == tonumber(count) and nil == width ) then <br />
width = count<br />
count = nil<br />
end<br />
if ( nil == liststyle ) then<br />
if ( "upper-alpha" == group or "lower-alpha" == group or "upper-roman" == group or "lower-roman" == group or "upper-greek" == group or "lower-greek" == group ) then<br />
liststyle = group<br />
else<br />
liststyle = config.default_liststyle<br />
end<br />
end<br />
local params = {}<br />
params.class = "refbegin"<br />
params.style = z.wikitext.liststyle(liststyle)<br />
if ( nil ~= count ) then <br />
params.class = params.class .. " references-column-count references-column-count-" .. count<br />
params.style = params.style .. " " .. z.wikitext.columncountstyle(count)<br />
end <br />
if ( nil ~= width ) then<br />
params.class = params.class .. " references-column-width"<br />
params.style = params.style .. " " .. z.wikitext.columnwidthstyle(width)<br />
end<br />
local dlopen<br />
if ( nil ~= indent ) then<br />
dlopen = z.wikitext.OpenHTMLTag({name="dl",params={style="text-indent: -" .. (indentsize or "3.2") .. "em;"}})<br />
else<br />
dlopen = ""<br />
end<br />
return z.wikitext.OpenHTMLTag({name="div",params=params}) .. dlopen<br />
end<br />
<br />
function refend0(frame, config, args)<br />
local indent = args.indent<br />
local dlclose<br />
if ( nil ~= indent ) then<br />
dlclose = "</dl>"<br />
else<br />
dlclose = ""<br />
end<br />
return dlclose .. "</div>"<br />
end<br />
<br />
-- This is used by {{doi}} to create DOI links in the style used in citations.<br />
function z.doi(frame)<br />
local pframe = frame:getParent()<br />
local id = pframe.args.id or pframe.args[1] or ""<br />
return doi(id)<br />
end<br />
<br />
-- This is used by {{ISSN}} to create ISSN links in the style used in citations.<br />
function z.ISSN(frame)<br />
local pframe = frame:getParent()<br />
local Name = pframe.args[1] or ""<br />
return hideinprint("[[International Standard Serial Number|ISSN]]&nbsp;[http://www.worldcat.org/search?fq=x0:jrnl&q=n2:" .. Name .. " " .. Name .. "]")<br />
end<br />
<br />
-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.<br />
function z.SFNID(frame)<br />
local pframe = frame:getParent()<br />
return anchorid('FOOTNOTE', pframe.args)<br />
end<br />
<br />
-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.<br />
function z.Harvard(frame)<br />
local pframe = frame:getParent()<br />
return crossref(frame, pframe.args)<br />
end<br />
<br />
-- This is used by templates such as {{sfn}} to create the entire cross-reference.<br />
function z.sfn(frame)<br />
local pframe = frame:getParent()<br />
pframe.args.Postscript = pframe.args.postscript or pframe.args.ps or ".";<br />
<br />
local content = crossref(frame, 'CITEREF', pframe.args)<br />
local args = { name = refid( 'FOOTNOTE', pframe.args) }<br />
return createTag({name = "ref", contents = content, params = args}, frame)<br />
end<br />
<br />
-- This is used by template {{r}}.<br />
function z.r(frame)<br />
local pframe = frame:getParent()<br />
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself<br />
local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template<br />
args.page1 = args.page1 or args.page<br />
local text = ""<br />
-- This would be shorter using ipairs(), but that doesn't work on an arguments table supplied to a template.<br />
local index = 1<br />
while args[index] ~= nil do<br />
local arg = args[index]<br />
local t = r0(frame, arg, args.group, args["page" .. index])<br />
text = text .. t<br />
index = index + 1<br />
end<br />
return text<br />
end<br />
<br />
-- This is used by template {{ref label}}.<br />
function z.reflabel(frame)<br />
local pframe = frame:getParent()<br />
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself<br />
local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template<br />
local P1 = args[1] or ""<br />
local P2 = args[2] or ""<br />
local P3 = args[3] or ""<br />
local id = nil<br />
local contents = "[[#endnote_" .. P1 .. P3 .. "|&#91;" .. P2 .. "&#93;]]"<br />
local params = {}<br />
params.class="reference"<br />
if ( args.noid == nil or args.noid == "" ) then params.id = "ref_" .. P1 .. P3 end<br />
return createTag({name="sup",contents=contents,params=params})<br />
end<br />
<br />
-- This is used by template {{note label}}.<br />
function z.notelabel(frame)<br />
local pframe = frame:getParent()<br />
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself<br />
local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template<br />
local id = args[1] or ""<br />
local arrow = args[3] or ""<br />
local postscript = args[4] or ""<br />
local contents <br />
if arrow ~= "" then<br />
local sup_arrow = createTag({name="sup",contents=arrow,params={}})<br />
contents = "[[#ref_" .. id .. arrow .. "|<b>" .. sup_arrow .. "</b>]]" .. postscript<br />
if "none" == arrow then arrow = "^" end -- Change this AFTER using it in the ID parameter and the contents.<br />
else<br />
contents = (args[2] or "") .. postscript<br />
end<br />
local params = { class="citation wikicite" }<br />
if id ~= "" and ( args.noid == nil or args.noid == "" ) then <br />
params.id = mw.uri.anchorEncode("endnote_" .. id .. arrow)<br />
end<br />
return createTag({name="span",contents=contents,params=params})<br />
end<br />
<br />
-- This is used by templates {{reflist}} and {{notelist}}.<br />
function z.reflist(frame)<br />
local pframe = frame:getParent()<br />
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself<br />
local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template<br />
return reflist0(frame, config, args)<br />
end<br />
<br />
-- This is used by template {{refbegin}}.<br />
function z.refbegin(frame)<br />
local pframe = frame:getParent()<br />
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself<br />
local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template<br />
return refbegin0(frame, config, args)<br />
end<br />
<br />
-- This is used by template {{refend}}.<br />
function z.refend(frame)<br />
local pframe = frame:getParent()<br />
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself<br />
local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template<br />
return refend0(frame, config, args)<br />
end<br />
<br />
-- This is used by template {{efn}}.<br />
function z.efn(frame)<br />
local pframe = frame:getParent()<br />
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself<br />
local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template<br />
return createTag({name="ref",contents=(args[1] or ""),params={name=args.name,group=config.default_group}}, frame)<br />
end<br />
<br />
return z<br />
---------------------------------------------------------------------</div>Florentyna