https://de.wikipedia.org/w/index.php?action=history&feed=atom&title=Modul%3ACitation Modul:Citation - Versionsgeschichte 2025-04-30T13:10:34Z Versionsgeschichte dieser Seite in Wikipedia MediaWiki 1.44.0-wmf.25 https://de.wikipedia.org/w/index.php?title=Modul:Citation&diff=117555091&oldid=prev Florentyna: 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 &quot;mw.text&quot;<br /> <br /> local z = {<br /> wikitext = require(&quot;Module:Wikitext&quot;),<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( &quot;^%s*(.-)%s*$&quot; );<br /> end<br /> <br /> function hideinprint(content)<br /> return content<br /> end<br /> <br /> function onlyinprint(content)<br /> return &quot;&quot;<br /> end<br /> <br /> -- This returns a string with HTML character entities for wikitext markup characters.<br /> function wikiescape(text)<br /> text = text:gsub( &#039;[&amp;\&#039;%[%]{|}]&#039;, { <br /> [&#039;&amp;&#039;] = &#039;&amp;#38;&#039;, <br /> [&quot;&#039;&quot;] = &#039;&amp;#39;&#039;, <br /> [&#039;[&#039;] = &#039;&amp;#91;&#039;, <br /> [&#039;]&#039;] = &#039;&amp;#93;&#039;, <br /> [&#039;{&#039;] = &#039;&amp;#123;&#039;, <br /> [&#039;|&#039;] = &#039;&amp;#124;&#039;, <br /> [&#039;}&#039;] = &#039;&amp;#125;&#039; } );<br /> return text;<br /> end<br /> <br /> function createTag(t, frame)<br /> local name = t.name or &quot;!-- --&quot;<br /> local content = t.contents or &quot;&quot;<br /> local attrs = {}<br /> if ( z.extensiontags[name] ) then<br /> -- We have to preprocess these, so that they are properly turned into so-called &quot;strip markers&quot; in the generated wikitext.<br /> if ( not frame ) then error (&quot;Please supply an extra frame argument to the createTag() function.&quot;) end<br /> local params = {}<br /> for n,v in pairs(t.params) do<br /> table.insert(params, &quot;|&quot; .. n .. &quot;=&quot; .. v)<br /> end<br /> return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. table.concat(params) .. &quot;}}&quot;)<br /> else <br /> for n,v in pairs(t.params) do<br /> if (v) then<br /> table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)<br /> else<br /> table.insert(attrs, n)<br /> end<br /> end<br /> if (&quot;&quot; == content) then<br /> return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;<br /> else<br /> return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;<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&#039;re only caring about ASCII chars<br /> s = string.gsub( s, &#039;[&quot;&amp;\&#039;&lt;=&gt;%[%]{|}]&#039;, {<br /> [&#039;&quot;&#039;] = &#039;&amp;#34;&#039;,<br /> [&#039;&amp;&#039;] = &#039;&amp;#38;&#039;,<br /> [&quot;&#039;&quot;] = &#039;&amp;#39;&#039;,<br /> [&#039;&lt;&#039;] = &#039;&amp;#60;&#039;,<br /> [&#039;=&#039;] = &#039;&amp;#61;&#039;,<br /> [&#039;&gt;&#039;] = &#039;&amp;#62;&#039;,<br /> [&#039;[&#039;] = &#039;&amp;#91;&#039;,<br /> [&#039;]&#039;] = &#039;&amp;#93;&#039;,<br /> [&#039;{&#039;] = &#039;&amp;#123;&#039;,<br /> [&#039;|&#039;] = &#039;&amp;#124;&#039;,<br /> [&#039;}&#039;] = &#039;&amp;#125;&#039;,<br /> } )<br /> s = string.sub( string.gsub( &#039;\n&#039; .. s, &#039;\n[#*:;]&#039;, {<br /> [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,<br /> [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,<br /> [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,<br /> [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,<br /> } ), 2 )<br /> s = string.gsub( s, &#039;://&#039;, &#039;&amp;#58;//&#039; )<br /> s = string.gsub( s, &#039;ISBN &#039;, &#039;ISBN&amp;#32;&#039; )<br /> s = string.gsub( s, &#039;RFC &#039;, &#039;RFC&amp;#32;&#039; )<br /> <br /> return s<br /> end<br /> <br /> function externallinkid(args)<br /> local sep = args.separator or &quot;&amp;nbsp;&quot;<br /> args.suffix = args.suffix or &quot;&quot;<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(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. url_string .. args.suffix .. &quot; &quot; .. nowiki(args.id) .. &quot;]&quot;)<br /> <br /> return t0 .. t1<br /> end<br /> <br /> function doi(id, inactive, nocat)<br /> local cat = &quot;&quot;<br /> local text;<br /> if ( inactive ~= nil ) then <br /> text = &quot;[[Digital object identifier|doi]]:&quot; .. id;<br /> cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;<br /> inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; <br /> else <br /> text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})<br /> inactive = &quot;&quot; <br /> end<br /> if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then<br /> cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. &#039;&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;&#039;<br /> end<br /> if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; 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, &#039;Y&#039;, str )<br /> if good then <br /> return result;<br /> else<br /> return &#039;&#039;;<br /> end<br /> end<br /> <br /> function anchorid(label, args)<br /> local P1 = trim(args[1]) or &quot;&quot;<br /> local P2 = trim(args[2]) or &quot;&quot;<br /> local P3 = trim(args[3]) or &quot;&quot;<br /> local P4 = trim(args[4]) or &quot;&quot;<br /> local P5 = trim(args[5]) or &quot;&quot;<br /> local anchor = P1 .. P2 .. P3 .. P4 .. P5;<br /> if anchor ~= &#039;&#039; 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 &quot;&quot;<br /> local pp = args.pp or &quot;&quot;<br /> local loc = args.loc or &quot;&quot;<br /> return anchorid(label, args) .. p .. pp .. loc <br /> end<br /> <br /> function name(args)<br /> local P1 = trim(args[1]) or &quot;&quot;<br /> if ( args[5] ~= nil) then<br /> return P1 .. &quot; et al.&quot;<br /> else<br /> local P2 = trim(args[2]) or &quot;&quot;<br /> local P3 = trim(args[3]) or &quot;&quot; <br /> local P4 = trim(args[4]) or &quot;&quot;<br /> if ( args[4] ~= nil ) then<br /> P4 = &quot; &quot; .. P4<br /> P3 = &quot; &amp;amp; &quot; .. P3<br /> P2 = &quot;, &quot; .. P2<br /> elseif ( args[3] ~= nil ) then<br /> P3 = &quot; &quot; .. P3<br /> P2 = &quot; &amp;amp; &quot; .. P2<br /> elseif ( args[2] ~= nil ) then<br /> P2 = &quot; &quot; .. 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 &quot;&quot;<br /> local RB = config.BracketRight or &quot;&quot;<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 == &#039;&#039; then<br /> page = args.p or args.page;<br /> end <br /> if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end<br /> if ( page ~= nil ) then<br /> local pagesep = config.PageSep or &quot;, p.&amp;nbsp;&quot;<br /> loc = loc .. pagesep .. page<br /> end<br /> if ( pages ~= nil ) then<br /> local pagessep = config.PagesSep or &quot;, pp.&amp;nbsp;&quot;<br /> loc = loc .. pagessep .. pages<br /> end <br /> local pagename = args.pagename or &quot;&quot;<br /> local ps = args.Postscript or &quot;&quot;<br /> return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps<br /> end<br /> <br /> function r0(frame, name, group, page)<br /> if ( name == nil ) then return &quot;&quot; end<br /> if ( group == nil ) then group = &quot;&quot; end<br /> local p = &quot;&quot;<br /> if ( page ~= nil ) then <br /> local contents = &quot;:&quot; .. page<br /> p = createTag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) <br /> end<br /> return createTag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p<br /> end<br /> <br /> function reflist0(frame, config, args)<br /> local contents = args.refs or &quot;&quot;<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 ( &quot;upper-alpha&quot; == group or &quot;lower-alpha&quot; == group or &quot;upper-roman&quot; == group or &quot;lower-roman&quot; == group or &quot;upper-greek&quot; == group or &quot;lower-greek&quot; == group ) then<br /> liststyle = group<br /> else<br /> liststyle = config.default_liststyle<br /> end<br /> end<br /> local params = {}<br /> params.class = &quot;reflist&quot; <br /> params.style = z.wikitext.liststyle(liststyle)<br /> if ( nil ~= count ) then <br /> params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count<br /> params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)<br /> end <br /> if ( nil ~= width ) then<br /> params.class = params.class .. &quot; references-column-width&quot;<br /> params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)<br /> end<br /> local references = createTag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)<br /> return createTag({name=&quot;div&quot;,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 ( &quot;upper-alpha&quot; == group or &quot;lower-alpha&quot; == group or &quot;upper-roman&quot; == group or &quot;lower-roman&quot; == group or &quot;upper-greek&quot; == group or &quot;lower-greek&quot; == group ) then<br /> liststyle = group<br /> else<br /> liststyle = config.default_liststyle<br /> end<br /> end<br /> local params = {}<br /> params.class = &quot;refbegin&quot;<br /> params.style = z.wikitext.liststyle(liststyle)<br /> if ( nil ~= count ) then <br /> params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count<br /> params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)<br /> end <br /> if ( nil ~= width ) then<br /> params.class = params.class .. &quot; references-column-width&quot;<br /> params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)<br /> end<br /> local dlopen<br /> if ( nil ~= indent ) then<br /> dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})<br /> else<br /> dlopen = &quot;&quot;<br /> end<br /> return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,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 = &quot;&lt;/dl&gt;&quot;<br /> else<br /> dlclose = &quot;&quot;<br /> end<br /> return dlclose .. &quot;&lt;/div&gt;&quot;<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 &quot;&quot;<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 &quot;&quot;<br /> return hideinprint(&quot;[[International Standard Serial Number|ISSN]]&amp;nbsp;[http://www.worldcat.org/search?fq=x0:jrnl&amp;q=n2:&quot; .. Name .. &quot; &quot; .. Name .. &quot;]&quot;)<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(&#039;FOOTNOTE&#039;, 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 &quot;.&quot;;<br /> <br /> local content = crossref(frame, &#039;CITEREF&#039;, pframe.args)<br /> local args = { name = refid( &#039;FOOTNOTE&#039;, pframe.args) }<br /> return createTag({name = &quot;ref&quot;, 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 = &quot;&quot;<br /> -- This would be shorter using ipairs(), but that doesn&#039;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[&quot;page&quot; .. 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 &quot;&quot;<br /> local P2 = args[2] or &quot;&quot;<br /> local P3 = args[3] or &quot;&quot;<br /> local id = nil<br /> local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;<br /> local params = {}<br /> params.class=&quot;reference&quot;<br /> if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end<br /> return createTag({name=&quot;sup&quot;,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 &quot;&quot;<br /> local arrow = args[3] or &quot;&quot;<br /> local postscript = args[4] or &quot;&quot;<br /> local contents <br /> if arrow ~= &quot;&quot; then<br /> local sup_arrow = createTag({name=&quot;sup&quot;,contents=arrow,params={}})<br /> contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript<br /> if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.<br /> else<br /> contents = (args[2] or &quot;&quot;) .. postscript<br /> end<br /> local params = { class=&quot;citation wikicite&quot; }<br /> if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then <br /> params.id = mw.uri.anchorEncode(&quot;endnote_&quot; .. id .. arrow)<br /> end<br /> return createTag({name=&quot;span&quot;,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=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)<br /> end<br /> <br /> return z<br /> ---------------------------------------------------------------------</div> Florentyna